package com.tensquare.jwt;

import io.jsonwebtoken.*;
import javafx.scene.input.DataFormat;

import java.text.SimpleDateFormat;

public class ParseJwtTest {

    public static void main(String[] args) {
        Claims claims = Jwts.parser()
                .setSigningKey("test")
                .parseClaimsJws("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2NjYiLCJzdWIiOiJ0b20iLCJpYXQiOjE1NjE4MDM5ODIsImV4cCI6MTU2MTgwNDA0Miwicm9sZSI6ImFkbWluIn0.Ig9gO7Nv8qqpAV7VC0znuR7qHeVcukAQ5cb0x3yItvU")
                .getBody();
        System.out.println("登录时间" + claims + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss").format(claims.getIssuedAt()));
        System.out.println("过期时间" + claims  + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss").format(claims.getExpiration()));
        System.out.println("用户身份" + claims.get("role"));
    }

}
